/*
 * ikakeibo 0.6.0
 * Copyright (C)2009 wateray and contributors
 * wateray@gmail.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

package com.wateray.ipassbook.ui.perspective;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import javax.swing.JSplitPane;

import com.wateray.ipassbook.ui.view.contentPanel.PageContainer;
import com.wateray.ipassbook.ui.view.contentPanel.IPage;
import com.wateray.ipassbook.ui.view.navigator.CurtainPaneNavigator;

/**
 * @author wateray
 * @create 2009-5-1
 */
public class CurtainCardPerspective {

	/** the main panel of this perspective.*/
	private static JPanel thisPerspective;
	
	/** the splitPanel for this perspective.*/
	private static JSplitPane splitPanel;
	
	
	public static JPanel getInstance(){
		if(thisPerspective == null){
			thisPerspective = new JPanel(new BorderLayout());
			thisPerspective.add(getSplitPanel());
		}
		
		return thisPerspective;
	}
	private static JSplitPane getSplitPanel(){
		if(splitPanel == null){
			splitPanel = new JSplitPane();
			splitPanel.setOrientation(JSplitPane.HORIZONTAL_SPLIT );
			//splitPanel.setAutoscrolls(true);
			splitPanel.setDividerLocation(0.35);
			splitPanel.setOneTouchExpandable(true);
			splitPanel.setLeftComponent(CurtainPaneNavigator.getInstance().getCurtainPanelView());
			splitPanel.setRightComponent(getContentPanel());		
		}
		
		return splitPanel;
	}
	
	public static void setDefaultComponent(IPage cardComponet){
		getContentPanel().setDefaultPage(cardComponet);
	}
	
	public static PageContainer getContentPanel(){
		return PageContainer.getInstance();
	}
	
}
